﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using YEngineLib;
using YEngineLib.Animation;

namespace Spyfall.Objects
{
    class PowerUp : Object
    {
        public Texture2D tex;
        //List<Animation> obstacleAnimationList;
        //Animation idleAnimation;

        //public Vector2 origin;
        public Vector2 position;
        public Vector2 velocity;


        public PowerUp()
        {
            ObjectID = Object_Type.POWERUP;

            //// Animation Stuff Start ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            //texture = YEngine.Game.Content.Load<Texture2D>("Graphics/obstacle01");
            //obstacleAnimationList = new List<Animation>();
            //idleAnimation = new Animation();
            //idleAnimation.Initialize(texture, position, 94, 60, 2, 0.1f, Color.White, 1f, true);
            //obstacleAnimationList.Add(idleAnimation);
            //// Animation Stuff End   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        }

        public void Initialize(Texture2D texture, float positionX, float positionY, float velocityX, float velocityY)
        {
            tex = texture;
            position.X = positionX;
            position.Y = positionY;
            velocity.X = velocityX;
            velocity.Y = velocityY;

            ColRect = new Rectangle((int)position.X, (int)position.Y, this.tex.Width, this.tex.Height / 3);
        }

        public override void Update(float deltaTime)  
        {
            //for (int i = obstacleAnimationList.Count - 1; i >= 0; i--)
            //{
            //    obstacleAnimationList[i].Update(deltaTime);
            //    if (obstacleAnimationList[i].Active == false)
            //    {
            //        obstacleAnimationList.RemoveAt(i);
            //    }
            //}
            //// Animation Stuff End   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

            //MOVEMENT
            position.Y += (velocity.Y * deltaTime);
            ColRect = new Rectangle((int)position.X, (int)position.Y, this.tex.Width, this.tex.Height / 3);
   
            //// Animation Stuff Start ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            //// Animation Stuff Start ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            //for (int i = 0; i < obstacleAnimationList.Count; i++)
            //{
            //    obstacleAnimationList[i].Draw(spriteBatch);
            //}
            //// Animation Stuff End   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

            YEngine.Graphics.SpriteBatch.Draw(tex, position, Color.White);

            // draw collision rects
            Texture2D dummyTexture;
            Rectangle dummyRectangle;
            dummyRectangle = this.ColRect;
            dummyTexture = new Texture2D(YEngine.Game.GraphicsDevice, 1, 1);
            dummyTexture.SetData(new Color[] { Color.White });


            //YEngine.Graphics.SpriteBatch.Draw(dummyTexture, dummyRectangle, Color.White);

        }

        public override bool Collide(Object tar)
        {
            return ColRect.Intersects(tar.ColRect);
        }
    }
}

